package com.itheima.duotai2;

public class Demo01 {
    public static void main(String[] args) {
         /*int i =130;
         byte b= (byte) i;
        System.out.println(b);*/
         useAnimal(new Pig());
         Dog dog = new Dog();
         //Dog dog2= new Cat();
      //boolean flag= 10  instanceof int ;
        boolean flag= dog instanceof  Dog;

        String s="111";
        //StringBuilder sb= new StringBuilder("111");
        System.out.println(s.equals(111));
    }


    //需要一个方法  来使用狗   使用猫
    public  static void useDog(Dog a){
        a.eat();
        a.watchHome();
    }
    public static void useCat(Cat a){
        a.eat();
    }

    public static void useAnimal (Animal a){
        a.eat();
        if(a instanceof Dog){
            Dog dog= (Dog) a;
            dog.watchHome();
        }

    }
}
abstract class Animal{
    public abstract  void eat();
}
class Dog extends Animal{

    @Override
    public void eat() {
        System.out.println("狗吃肉");
    }

    public void watchHome(){
        System.out.println("狗看家");
    }
}
class Cat extends Animal{

    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }
}
class Pig extends Animal{

    @Override
    public void eat() {
        System.out.println("猪吃饲料");
    }
}